﻿/**
* ...
* @author Default
* @version 0.1
*/

package com.crlclr.ui {
	import com.crl.core.IResizeable;
	import com.crl.managers.ResizeableManager;
	import com.crl.ui.controls.Component;
	import com.crlclr.events.*;
	import com.crlclr.managers.*;
	import com.crlclr.utils.QSize;
	
	import flash.events.*;
	
	public class QToolBar extends Component implements IResizeable {
		private var skinID:String = "toolBarSkin";
		private var skin:*;
		
		
		private var pad:int = 8;
		private var padL:int;
		private var padR:int;
		public function QToolBar() {
			super();
		}
		
		protected override function create():void {
			
			var skinClass:Class = SkinManager.getInstance().getClass(skinID);
			skin = new skinClass();
			addChild(skin);
			
			ResizeableManager.getInstance().add(this);
		}
		protected override function init():void {
			padL = skin.bg.left.width;
			padR = skin.bg.right.width;
		}
		public function pageChange(event:BookEvent):void {
			currentIndex=event.page.index;
		}
		
		
		public function set currentIndex(index:int):void {
			skin.pager.currentNumber.text = index + 1;
		}
		public function set total(num:Number):void {
			skin.pager.totalNumber.text = num;
		}
		
		public override function resize(w:int,h:int):void{
			skin.bg.center.width = w - padL - padR+pad+4;
			skin.bg.right.x = w - padR+pad;
			skin.pager.x = w - skin.pager.width;
		}
		
		
		public function getSize():QSize {
			var h:int = 25;
			return new QSize(this.width, h);
		}
		
	}
	
}
